//
//  MantisRightRichTextTableViewCell.m
//  IMMantisSDK_Example
//
//  Created by 陈志亮 on 2021/4/6.
//  Copyright © 2021 chenzhiliang. All rights reserved.
//

#import "MantisRightRichTextTableViewCell.h"

@implementation MantisRightRichTextTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setUpView];
    }
    return self;
}

-(void)setUpView{
    [super setUpView];
}


-(void)reloadCellModel:(MantisCellBaseModel *)data{
    [super reloadCellModel:data];
    NSString*imgStr=data.imgUrl;
    if (imgStr.length>0) {
        [self.avaterView setImageWithURL:[NSURL URLWithString:imgStr] placeholder:[UIImage imageNamed:@"chat_visitor_avater"]];
    }
   
    MantisRichTextModel*newData=( MantisRichTextModel*)data;
    self.contentLabel.attributedText=newData.richStr;
    
    CGFloat bgWidth =newData.contentSize.width+20;
    CGFloat bgHeight =newData.contentSize.height+20;
    
  
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.avaterView.mas_left).offset(-adaptWidth750(20));
        make.top.equalTo(self.avaterView);
        make.width.mas_equalTo(bgWidth);
        make.height.mas_equalTo(bgHeight);
    }];
 
    
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(10);
        make.bottom.mas_equalTo(-10);
        make.right.mas_equalTo(-10);
      }];
   

    [self.errorBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.bgView.mas_left).offset(-adaptWidth750(20));
        make.centerY.equalTo(self.contentLabel);
    }];
    
    
    CGSize labelSize =CGSizeMake(bgWidth, bgHeight);
    [self setThreeCorner:labelSize bgView:self.bgView];

}





- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
